import axios from 'axios';
import query from 'query-string';

const BASE_URL = '/wms/outbound/sell/order';

export interface OutboundResponse {
    id?: number;
    warehouseId?: number;
    warehouseShelfId?: number;
    memberId?: number;
    orderId?: number;
    orderNo: string;
    receiveName?: string;
    receiveAddress: string;
    receivePhone?: string;
    expressNo?: string;
    expressCode?: string;
    expressFreight?: string;
    payType?: number;
    totalAmount?: number;
    freightAmount?: number;
    promotionAmount?: number;
    pointAmount?: number;
    couponAmount?: number;
    adminDiscountAmount?: number;
    payAmount?: number;
    orderComment?: string;
    sellOutboundOrderStatus?: number;
    outboundTime?: string;

    createdBy?: string;
    updatedBy?: string;
    createdAt?: string;
    updatedAt?: string;
}

// 管理员添加命令
export interface OutboundSaveCommand {
    id?: number;
    warehouseId?: number;
    warehouseShelfId?: number;
    memberId?: number;
    orderId?: number;
    orderNo: string;
    receiveName?: string;
    receiveAddress: string;
    receivePhone?: string;
    expressNo?: string;
    expressCode?: string;
    expressFreight?: string;
    payType?: number;
    totalAmount?: number;
    freightAmount?: number;
    promotionAmount?: number;
    pointAmount?: number;
    couponAmount?: number;
    adminDiscountAmount?: number;
    payAmount?: number;
    orderComment?: string;
    sellOutboundOrderStatus?: number;
    outboundTime?: string;
}

export interface OutboundParam {
    memberId?: string;
    orderNo?: string;
    receiveName?: string;
    page?: number,
    size?:number,
    sort?:Array<string>;
}

export interface OutboundResponseList {
    list: OutboundResponse[];
    total: number;
}

// 通过id获取管理员详情信息
export function getOutbound(id: number) {
    return axios.get<OutboundResponse>(`${BASE_URL}/${id}`);
}

// 通过OutboundParam参数获取分页列表
export function pageOutbound(params: OutboundParam) {
    return axios.get<OutboundResponseList>(`${BASE_URL}/page`, {
        params, paramsSerializer: (obj) => {
            return query.stringify(obj);
        }
    })
}

// 添加管理员
export function addOutbound(params: OutboundSaveCommand) {
    return axios.post(`${BASE_URL}`, params);
}

// 更新管理员
export function updateOutbound(params: OutboundSaveCommand) {
    return axios.put(`${BASE_URL}`, params);
}


// 批量删除管理员
export function deleteOutbound(ids: number | Array<number>) {
    return axios.delete(`${BASE_URL}/${ids}`);
}